//
//  YSY_SkillDetail_ViewController.m
//  GoodManNews
//
//  Created by dllo on 16/1/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "YSY_SkillDetail_ViewController.h"
#import "YSY_SkillDetail_View.h"
#import "YSY_Game_HeroDetailModel.h"

#define SKILLIMAGEURL(heroName,skillName) [NSString stringWithFormat:@"http://img.lolbox.duowan.com/abilities/%@_%@_64x64.png",heroName, skillName]
#define SKILLVIDEOURL(heroID,skillName) [NSString stringWithFormat:@"http://115.28.43.55/lol/index.php/HeroSdk/abilitiesVideo/hero_id/%@/ability/%@",heroID, skillName]

@interface YSY_SkillDetail_ViewController ()<SkillDetailViewSendChooseInfo>
@property (nonatomic, retain) YSY_SkillDetail_View *skillDetailView;    //技能详情页面
@property (nonatomic, retain) YSY_Game_HeroDetailModel *heroDetailModel;//英雄model
@property (nonatomic, retain) NSMutableArray *heroSkillArr;
@property (nonatomic, retain) NSString *currentSkillName;       //当前技能名称
@end

@implementation YSY_SkillDetail_ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor =[UIColor  whiteColor];
    [self createView];
    
}
- (void)dealloc
{
    [_heroSkillArr release];
    [_heroDetailModel release];
    [_skillDetailView release];
    [super dealloc];
}
- (void)createView {
    
    self.skillDetailView = [YSY_SkillDetail_View new];
    self.skillDetailView.delegate = self;
    
    [self createSkillVideoButton];
    [self.view addSubview:self.skillDetailView];
    [self.skillDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
        make.edges.lessThanOrEqualTo(self.view);
    }];
    
    //创建英雄详细模板
    self.heroDetailModel = [[YSY_Game_HeroDetailModel alloc]  init];
}

#pragma mark - 数据
//给SkillDetailView添加数据
- (void)addDataToSkillDetailHeadView:(YSY_Game_HeroDetailModel *)heroModel {
    self.heroDetailModel = heroModel;
    
    [self.skillDetailView.skill_B_image sd_setImageWithURL:[NSURL URLWithString:SKILLIMAGEURL(heroModel.name,@"B")] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    [self.skillDetailView.skill_Q_image sd_setImageWithURL:[NSURL URLWithString:SKILLIMAGEURL(heroModel.name,@"Q")] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    [self.skillDetailView.skill_W_image sd_setImageWithURL:[NSURL URLWithString:SKILLIMAGEURL(heroModel.name,@"W")] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    [self.skillDetailView.skill_E_image sd_setImageWithURL:[NSURL URLWithString:SKILLIMAGEURL(heroModel.name,@"E")] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    [self.skillDetailView.skill_R_image sd_setImageWithURL:[NSURL URLWithString:SKILLIMAGEURL(heroModel.name,@"R")] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    
    [self addDataToSkillDetailView:1];
}
//技能视频按钮
- (void) createSkillVideoButton {
    [self.skillDetailView.skillVideo_btn  addTarget:self action:@selector(skillVideoBAction) forControlEvents:UIControlEventTouchUpInside];
}
//技能按钮方法
- (void)skillVideoBAction {
    NSLog(@"点击:%@", SKILLVIDEOURL(self.heroDetailModel.MId,self.currentSkillName));
}
//技能详情页面
- (void)addDataToSkillDetailView:(NSInteger)index {
    switch (index) {
        case 1:
            
        {
            self.currentSkillName = [NSString stringWithFormat:@"%@_%@", self.heroDetailModel.name, @"B"];
            self.skillDetailView.skillNameL.text = [NSString stringWithFormat:@"%@ (被动)",self.heroDetailModel.skill_B[@"name"]];
            self.skillDetailView.skillsDetailTextV.text = [NSString stringWithFormat:@"%@\n\n%@",self.heroDetailModel.skill_B[@"description"], self.heroDetailModel.skill_B[@"effect"]];
        }
            break;
        case 2:
            self.currentSkillName = [NSString stringWithFormat:@"%@_%@", self.heroDetailModel.name, @"Q"];
            self.skillDetailView.skillNameL.text = [NSString stringWithFormat:@"%@ (Q)",self.heroDetailModel.skill_Q[@"name"]];
            self.skillDetailView.skillsDetailTextV.text = [NSString stringWithFormat:@"%@\n\n%@\n\n消耗:%@\n冷却:%@\n范围:%@",self.heroDetailModel.skill_Q[@"description"],self.heroDetailModel.skill_Q[@"effect"], self.heroDetailModel.skill_Q[@"cost"], self.heroDetailModel.skill_Q[@"cooldown"], self.heroDetailModel.skill_Q[@"range"]];
            break;
        case 3:
            self.currentSkillName = [NSString stringWithFormat:@"%@_%@", self.heroDetailModel.name, @"W"];
            self.skillDetailView.skillNameL.text = [NSString stringWithFormat:@"%@ (W)",self.heroDetailModel.skill_W[@"name"]];
            self.skillDetailView.skillsDetailTextV.text = [NSString stringWithFormat:@"%@\n\n%@\n\n消耗:%@\n冷却:%@\n范围:%@",self.heroDetailModel.skill_W[@"description"],self.heroDetailModel.skill_W[@"effect"], self.heroDetailModel.skill_W[@"cost"], self.heroDetailModel.skill_W[@"cooldown"], self.heroDetailModel.skill_W[@"range"]];
            break;
        case 4:
            self.currentSkillName = [NSString stringWithFormat:@"%@_%@", self.heroDetailModel.name, @"E"];
            self.skillDetailView.skillNameL.text = [NSString stringWithFormat:@"%@ (E)",self.heroDetailModel.skill_E[@"name"]];
            self.skillDetailView.skillsDetailTextV.text = [NSString stringWithFormat:@"%@\n\n%@\n\n消耗:%@\n冷却:%@\n范围:%@",self.heroDetailModel.skill_E[@"description"],self.heroDetailModel.skill_E[@"effect"], self.heroDetailModel.skill_E[@"cost"], self.heroDetailModel.skill_E[@"cooldown"], self.heroDetailModel.skill_E[@"range"]];
            break;
        case 5:
            self.currentSkillName = [NSString stringWithFormat:@"%@_%@", self.heroDetailModel.name, @"R"];
            self.skillDetailView.skillNameL.text = [NSString stringWithFormat:@"%@ (R)",self.heroDetailModel.skill_R[@"name"]];
            self.skillDetailView.skillsDetailTextV.text = [NSString stringWithFormat:@"%@\n\n%@\n\n消耗:%@\n冷却:%@\n范围:%@",self.heroDetailModel.skill_R[@"description"],self.heroDetailModel.skill_R[@"effect"], self.heroDetailModel.skill_R[@"cost"], self.heroDetailModel.skill_R[@"cooldown"], self.heroDetailModel.skill_R[@"range"]];
            break;
        default:
            break;
    }

    
}
#pragma mark - 技能详细页面协议方法
- (void)sendChooseInfo:(NSInteger)index {
    [self addDataToSkillDetailView:index];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
